<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
include('lib/include.php');
$sub_total = 0;
$total_total = 0;
$tax_total = 0;
$shipping_total = 0;
$is_shipping = 1;

if (!isset($_SESSION['cart']))
{
	redirect('checkout.php');
}

if (isset($_POST['hidden_sub_total']))
{
	$sub_total = $_POST['hidden_sub_total'];
}

if (isset($_POST['hidden_shipping_total']))
{
	$shipping_total = $_POST['hidden_shipping_total'];
}

if (isset($_POST['hidden_tax_total']))
{
	$tax_total = $_POST['hidden_tax_total'];
}

if (isset($_POST['hidden_total_total']))
{
	$total_total = $_POST['hidden_total_total'];
}

if ($shipping_total <> 0)
{
	$is_shipping = 0;
}

$count = 1;		
$frm = '';
$frm .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="payForm">';
$frm .= '	<input type="hidden" name="cmd" value="_cart"/>';
$frm .= '<input type="hidden" name="upload" value="1">';
$frm .= '	<input type="hidden" name="business" value="9KV6R5HVXBSRJ"/>';
$frm .= '	<input type="hidden" name="lc" value="CA"/>';  
	
foreach ($_SESSION['cart'] as $arr)
{
	$frm .= '	<input type="hidden" name="item_name_'.$count.'" value="'.$arr['product_name'].'"/>';
	$frm .= '	<input type="hidden" name="item_number_'.$count.'" value="'.$arr['product_desc'].'"/>'; // Description	
	$frm .= '	<input type="hidden" name="amount_'.$count.'" value="'.$arr['unit_price'].'"/>';
	$frm .= '	<input type="hidden" name="quantity_'.$count.'" value="'.$arr['qty'].'" />';   
	$count = $count + 1;
}

$frm .= '	<input type="hidden" name="item_name_'.$count.'" value="Shipping"/>';
$frm .= '	<input type="hidden" name="amount_'.$count.'" value="'.$shipping_total.'"/>';
//$frm .= '	<input type="hidden" name="item_number_'.$count.'" value="Shipping fee"/>';
$frm .= '	<input type="hidden" name="item_name_'.($count+1).'" value="TAX-HST"/>';
$frm .= '	<input type="hidden" name="amount_'.($count+1).'" value="'.$tax_total.'"/>';
//$frm .= '	<input type="hidden" name="item_number_'.($count+1).'" value="Tax-HST"/>';
$frm .= '	<input type="hidden" name="currency_code" value="CAD"/>';
$frm .= '	<input type="hidden" name="button_subtype" value="services"/>';
$frm .= '	<input type="hidden" name="no_note" value="1"/>';
$frm .= '	<input type="hidden" name="no_shipping" value="'.$is_shipping.'"/>';
$frm .= '	<input type="hidden" name="rm" value="1"/>';
$frm .= '	<input type="hidden" name="return" value="http://www.888accessories.ca"/>';
$frm .= '	<input type="hidden" name="cancel_return" value="http://www.888accessories.ca/"/>';
$frm .= '	<input type="hidden" name="bn" value=""/>';
$frm .= '	<input type="hidden" name="custom" value="" />';        
$frm .= '</form>';	
	
	
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Paypal Transfer</title>
</head>

<body>
	
	<?php echo $frm; ?>
</body>
<script type="text/javascript">
	document.getElementById('payForm').submit();
</script>
</html>
